package BasicClass.Two;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Two_13 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int size = Integer.parseInt(reader.readLine());
        String[] nums = reader.readLine().split(" ");
        int[] arr = new int[size];
        for (int i = 0; i < size; i++) {
            arr[i]=Integer.parseInt(nums[i]);
        }
        Two_13 one20 = new Two_13();
        one20.process(arr,0,arr.length-1);
        StringBuilder builder = new StringBuilder();
        for (int i : arr) {
            builder.append(i+" ");
        }
        System.out.println(builder);
    }

    public void process(int[] arr,int L,int R){
        if(L<R){
            swap(arr, L+(int)(Math.random()*(R-L+1)),R);
            int[] ints = partition(arr, L, R);
            process(arr,L,ints[0]-1);
            process(arr,ints[1]+1,R);
        }
    }

    public int[] partition(int[] arr,int L,int R){
        int less = L-1;//<区的左边界
        int more = R;//>区的右边界
        while (L < more){
            if(arr[L] < arr[R]){
                swap(arr,++less,L++);
            }else if(arr[L] > arr[R]){
                swap(arr,--more,L);
            }else {
                L++;
            }
        }
        swap(arr,more,R);
        return new int[]{less+1,more};
    }

    private void swap(int[] arr,int i,int j) {
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
}
